//
//  YHBaseConfiguration.swift
//  SwiftProject
//
//  Created by qindong on 2021/3/19.
//

/// 用函数替换OC里的QMUICMI宏定义
var QMUICMI : QMUIConfiguration  {
    QMUIConfiguration.sharedInstance()?.applyInitialTemplate()
    return QMUIConfiguration.sharedInstance()!
}

//var miniProgramType : UInt {
//#if kTargetBeta
//    return 2
//#elseif kTargetProduct
//    return 0
//#elseif kTargetDevelop
//    return 2
//#elseif kTargetRelease
//    return 0
//#endif
//}

extension UIColor {
    /// 通用颜色
    static let color17 : UIColor = UIColor(named: "Color17")!
    static let color34 : UIColor = UIColor(named: "Color34")!
    static let color51 : UIColor = UIColor(named: "Color51")!
    static let color66 : UIColor = UIColor(named: "Color66")!
    static let color77 : UIColor = UIColor(named: "Color77")!
    static let color102 : UIColor = UIColor(named: "Color102")!
    static let color149 : UIColor = UIColor(named: "Color149")!
    static let color153 : UIColor = UIColor(named: "Color153")!
    static let color206 : UIColor = UIColor(named: "Color206")!
    static let color238 : UIColor = UIColor(named: "Color238")!
    static let colorMain : UIColor = UIColor(named: "ColorMain")!
    static let colorRed : UIColor = UIColor(named: "ColorRed")!
    static let colorMains : [UIColor] = [UIColor(named: "ColorMainLight")!, UIColor(named: "ColorMain")!]
}

extension UIImage {
    /// 通用图片
    static let defultImage : UIImage = UIImage(named: "background")!
    static let defultHeaderImage : UIImage = UIImage(named: "userheader_bg")!
    static let defultGoodImage : UIImage = UIImage(named: "defualt_good")!
}

class YHBaseConfiguration: NSObject {
    
    static var shared = YHBaseConfiguration()
    var configModel : WMConfigModel?
    
    private override init() {
        UITableView.appearance().estimatedRowHeight = 0
        UITableView.appearance().estimatedSectionFooterHeight = 0
        UITableView.appearance().estimatedSectionHeaderHeight = 0
//        UITableView.appearance().sectionHeaderHeight = .leastNormalMagnitude
//        UITableView.appearance().sectionFooterHeight = .leastNormalMagnitude
        UIButton.appearance().titleLabel?.font = .systemFont(ofSize: 15)
        UINavigationBar.appearance().tintColor = .black
        UICollectionView.appearance().backgroundColor = .white
        UIScrollView.appearance().keyboardDismissMode = .onDrag
        UIBarItem.appearance().setTitleTextAttributes([.font : UIFont.systemFont(ofSize: 12)], for: .normal)

        KRProgressHUD.appearance().activityIndicatorColors = ([.colorMain, .white])
        KRProgressHUD.appearance().maskType = .white

        IQKeyboardManager.shared.enable = true
        IQKeyboardManager.shared.shouldResignOnTouchOutside = true
        IQKeyboardManager.shared.toolbarDoneBarButtonItemText = "完成"

        if #available(iOS 15.0, *) {
            UITableView.appearance().sectionHeaderTopPadding = 0
        }
    }
    
    func requestConfig() {
        NetworkManager.manager.request(targetType: .initApp, showHud: false, responseModelType: NetworkBaseModel<WMConfigModel>.self) { responseModel in
            if responseModel.code != .successCode {
                return
            }
            self.configModel = responseModel.data
        }
    }
}

class WMConfigModel: BaseModel {
    var channelOpenExamine : Bool = false
    var education : Bool = false
    var relationship : Bool = false
    var loanAssistance : Bool = false
    var loanInformation : Bool = false
    var workInformation : Bool = false
    var face : Bool = false
    var customerServiceNum : String = ""
}
